package com.example.mvpdemo.simple5;

import com.example.mvpdemo.utils.OKHttpUitls;

public class WeatherModel_5 {
    String api = "http://v.juhe.cn/weather/index";
    String key = "150eb443405ccd2b2c5dac4d247791ae";

    public void weather(String cityname, onResult onResult) {
        String url = api + "?" + "cityname=" + cityname + "&key=" + key;
        OKHttpUitls okhttp = OKHttpUitls.getInstance();
        okhttp.setUrl(url);
        okhttp.setOnOKHttpGetListener(new OKHttpUitls.OKHttpGetListener() {
            @Override
            public void error(String error) {

                if (onResult != null)
                    onResult.fail(error);

            }

            @Override
            public void success(String json) {
                if (onResult != null)
                    onResult.success(json);

            }
        });
    }


    public interface onResult {

        void success(String result);

        void fail(String result);
    }
}
